package com.shopping.controller.front;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shopping.commons.controller.BaseController;
import com.shopping.commons.response.MessageResp;
import com.shopping.commons.util.CommonCode;
import com.shopping.response.UserResp;
import com.shopping.service.IAssessService;

/**
 * 前台评价的   Conroller
 * @author Administrator
 *
 */
@Controller
@RequestMapping("front/assess") 
public class FrontAssessController extends BaseController{

	@Autowired
	private IAssessService assessService;
	
	/**
	 * 根据id查询评价
	 * @param request
	 * @param param
	 * @return
	 */
	@RequestMapping(value="{id}",method=RequestMethod.GET)
	@ResponseBody  
	public MessageResp select(HttpServletRequest request,@PathVariable("id")Integer id){
		return assessService.selectById(id);
	}
	
	/**
	 * 增加评价
	 * @param request
	 * @param param
	 * @return
	 */
	@RequestMapping(value="add/{orderid}/{commid}")
	@ResponseBody  
	public MessageResp add(HttpServletRequest request,@PathVariable("orderid")Integer orderid,@PathVariable("commid")Integer commid,String content){
		UserResp retUser=this.getUser(request);
		if(retUser==null){
			MessageResp resp=new MessageResp();
			resp.setCode(CommonCode.FAIL);
			resp.setMsg("请先登录");
			return resp;
		}
		return assessService.add(retUser.getUserid(),orderid,commid,content);
	}

}
